package com.ss.user.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ss.user.dao.UserDao;
import com.ss.user.pojo.UserInfo;
/**
 * 用户管理
 * @author Administrator
 *
 */
@Repository("userDao")
public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {
	@Override
	public void addUser(UserInfo info) throws Exception {
		// TODO Auto-generated method stub
		this.getSqlMapClientTemplate().insert("user.addUser",info);
	}
	@Override
	public List<UserInfo> queryUser(UserInfo info) throws Exception {
		// TODO Auto-generated method stub
		return this.getSqlMapClientTemplate().queryForList("user.queryUser",info);
	}
	@Override
	public UserInfo getUserByName(String userName) throws Exception {
		// TODO Auto-generated method stub
		List list= this.getSqlMapClientTemplate().queryForList("user.getUserByName",userName);
		if(list!=null && list.size()>0){
			return (UserInfo)list.get(0);
		}else{
			return null;
		}
	}
	@Override
	public UserInfo getUserById(String id) throws Exception {
		// TODO Auto-generated method stub
		return (UserInfo)this.getSqlMapClientTemplate().queryForObject("user.getUserById",id);
	}
	@Override
	public int updateUser(UserInfo info) throws Exception {
		// TODO Auto-generated method stub
		return this.getSqlMapClientTemplate().update("user.updateUser",info);
	}
	@Override
	public void markLoginTime(String id) throws Exception {
		// TODO Auto-generated method stub
		this.getSqlMapClientTemplate().update("user.markLoginTime",id);
	}
	@Override
	public int auditUser(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		return this.getSqlMapClientTemplate().update("user.auditUser",map);
	}
	
}
